package com.harboursoftware.xstorage.stress


class StorageServletStressTest {
    //StorageServlet servlet
	def secretAccessKey = 'uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o'
//    @Before
//    void setUp() {
//        servlet = new StorageServlet()
//    }
//    
//    @After
//    void tearDown() {
//        servlet = null
//    }
    
    
//    @Test
//    void test_createStringToSign() { 
//        
//        MockHttpServletRequest request = new MockHttpServletRequest('get', '/photos/puppy.jpg')
//        request.setServerName("johnsmith" + Constants.XS_HOSTNAME_SUFFIX)
//        request.addHeader("Host", "johnsmith.s.x-storage.com")
//        request.addHeader("Date", "Tue, 27 Mar 2007 19:36:42 +0000")
//
//        def bucket = servlet.createBucket(request)
//        def object = servlet.createObject(request)
//        def headers = servlet.getHeaders(request)
//        def params = servlet.getParameters(request)
//
//        def beginTime = System.nanoTime()
//        for(int i=0; i<100000; i++){
//            servlet.createStringToSign(request.getMethod(), bucket, object, headers, params)
//        }
//        
//        def endTime = System.nanoTime()
//        println ((endTime - beginTime)/1000000) + 'ms'
//    }
	
//	@Test
//	void test_sign() {
//		MockHttpServletRequest request = new MockHttpServletRequest('PUT', '/db-backup.dat.gz')
//		request.setServerName('static.johnsmith.net')
//		request.addHeader("User-Agent", " curl/7.15.5")
//		request.addHeader("Host", "static.johnsmith.net")
//		request.addHeader("Date", "Tue, 27 Mar 2007 21:06:08 +0000");
//		request.addHeader("x-amz-acl", "public-read");
//		request.addHeader("content-type", "application/x-download");
//		request.addHeader("Content-MD5", "4gJE4saaMU4BqNR0kLY+lw==");
//		request.addHeader("X-Amz-Meta-ReviewedBy", "joe@johnsmith.net");
//		request.addHeader("X-Amz-Meta-ReviewedBy", "jane@johnsmith.net");
//		request.addHeader("X-Amz-Meta-FileChecksum", "0x02661779");
//		request.addHeader("X-Amz-Meta-ChecksumAlgorithm", "crc32");
//		request.addHeader("Content-Disposition", "attachment; filename=database.dat");
//		request.addHeader("Content-Encoding", "gzip");
//		request.addHeader("Content-Length", "5913339");
//		
//		def bucket = servlet.createBucket(request)
//		def object = servlet.createObject(request)
//		def headers = servlet.getHeaders(request)
//		def params = servlet.getParameters(request)
//		
//		def beginTime = System.nanoTime()
//		for(int i=0; i<10000; i++) {
//			def stringToSign = servlet.createStringToSign(request.getMethod(), bucket, object, headers, params)
//			def signature = servlet.sign(secretAccessKey, stringToSign)
//			//assert signature == 'C0FlOtU8Ylb9KDTpZqYkZPX91iI='
//		}
//		def endTime = System.nanoTime()
//		println ((endTime - beginTime)/1000000) + 'ms'
//	}
    
}
